<link rel="stylesheet" href="/NewAdmin/css/app.v1.css" />
<link rel="stylesheet" href="/NewAdmin/css/ace.min.css" />
<link rel="stylesheet" type="text/css" href="/Store/css/order/order.css" />
<link rel="stylesheet" type="text/css" href="/Store/css/order/order2.css" />
<link rel="stylesheet" type="text/css" href="/Store/css/order/op_express.css" />
<link rel="stylesheet" type="text/css" href="/Store/css/WdatePicker/skin/WdatePicker.css" />
<script src="/Store/css/WdatePicker/WdatePicker.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
	.modal-dialog{margin: 0;}
	li{list-style: none;}
	.y_cprice{font-style: normal;}
	#y_iprice,#y_button{display: none;}
	#y_button{margin-top: -5px;}
	.xprice{margin-top: -14px;float: right;font-style: initial;color: red;}
	.main-content{margin-left: 0px}
</style>

<script src="/Partner/static/js/jquery.min.js?v=2.1.4"></script>
<script src="/NewAdmin/js/bootstrap.min.js"></script>


<script src="/static/js/layer2.1/layer.js"></script>


<div class="main-content" id="mainContent">

	<div class="RIGHT">

		<!--顶部边框开始  -->
		<div class="tabmenu">
			<ul class="tab pngFix" style="padding: 0;">.
				<li>
					<a href="javascript:;" onclick="history.back(-1);">返回</a>
				</li>

			</ul>

		</div>
		<hr class="tabmenu_hr" style="border:1px solid #00C0FF;margin:0 0px 10px 20px;">
		<div class="main">

			<div class="mod-table">
				<div class="step-region">
					<ul class="ui-step ui-step-4">
						<li class="<egt name="order_info[ 'order_state'] " value='10'>ui-step-done</egt>">
						<div class="ui-step-title">买家下单</div>
						<div class="ui-step-number">1</div>
						<div class="ui-step-meta">
							<notempty name="order_info['add_time']">{:date('Y-m-d H:i:s',$order_info['add_time'])}</notempty>
						</div>
						</li>
						<li class="<egt name="order_info[ 'order_state'] " value='20'>ui-step-done</egt>">
						<div class="ui-step-title">买家付款</div>
						<div class="ui-step-number">2</div>
						<div class="ui-step-meta">
							<notempty name="order_info['payment_time']">{:date('Y-m-d H:i:s',$order_info['payment_time'])}</notempty>
						</div>
						</li>
						<li class="<egt name="order_info[ 'order_state'] " value='30'>ui-step-done</egt>">
						<div class="ui-step-title">商家发货</div>
						<div class="ui-step-number">3</div>
						<div class="ui-step-meta">
							<notempty name="order_info['shipping_time']">{:date('Y-m-d H:i:s',$order_info['shipping_time'])}</notempty>
						</div>
						</li>
						<li class="<egt name="order_info[ 'order_state'] " value='40'>ui-step-done</egt>">
						<div class="ui-step-title">交易完成</div>
						<div class="ui-step-number">4</div>
						<div class="ui-step-meta">
							<notempty name="order_info['finnshed_time']">{:date('Y-m-d H:i:s',$order_info['finnshed_time'])}</notempty>
						</div>
						</li>
					</ul>
				</div>
				<div class="step-region clearfix">
					<div class="info-region">
						<div class="info-div">订单信息</div>
						<table class="info-table">
							<tbody>
							<tr>
								<th>订单编号：</th>
								<td>{$order_info['order_sn']}</td>
							</tr>
							<tr style="display: table-row;">
								<th>订单类型：</th>
								<td>普通订单</td>
							</tr>
							<tr>
								<th>付款方式：</th>
								<td>{$order_info['payment_code']|default='未付款'}</td>
							</tr>
							<tr>
								<th>买家：</th>
								<td><span>{$order_info['buyer_name']}</span></td>
							</tr>
							</tbody>
						</table>
						<div class="dashed-line"></div>
						<table class="info-table">
							<tbody>
							<tr>
								<th>配送方式：</th>
								<td>商家配送</td>
							</tr>
							<!-- 物流 -->
							<tr>
								<th>收货信息：</th>
								<td>
									<php>
										$ProvinceInfo=getProvinceInfo($order_info['buyer_province']); $CityInfo=getCityInfo($order_info['buyer_city']); $DistrictInfo=getDistrictInfo($order_info['buyer_district']);
									</php>
									<p>{$ProvinceInfo['province_name']} {$CityInfo['city_name']} {$DistrictInfo['district_name']} {$order_info['buyer_address']}</p>

								</td>
							</tr>
							<tr>
								<th>买家留言：</th>
								<td>{$order_info['leavemessage']|default='未留言'}</td>
							</tr>

							<notempty name="order_info['shipping_code']">
								<tr>
									<th>运单编号：</th>
									<td>{$order_info['shipping_code']}&nbsp; <a target="_blank" href="http://www.baidu.com/s?wd=物流:{$order_info['shipping_code']}">({$order_info['shipping_name']})</a>
										<php>
											if($order_edit==1){
										</php>
										<eq name="order_info['order_state']" value="30">	<button class="zent-btn zent-btn-primary test-send-goods" onclick="operation('delivery',{$order_info['order_id']})" style="padding: 0 5px;height: 17px;line-height: 17px;font-size: 12px;">修改</button></eq>
										<php>}</php>
									</td>
								</tr>

							</notempty>
							</tbody>
						</table>
					</div>
					<php>
						if($order_info['tuanselect']==1){
						if($order_info['tuan_is_first_id']==0){
						$num=get_tuan($order_info['order_id']);
						}else{
						$num=get_tuan($order_info['tuan_is_first_id']);
						}

						}
					</php>
					<div class="state-region">
						<div style="padding: 0px 0px 30px 40px;">
							<div class="state-title"><span class="icon info">!</span>
								<eq name="vo['refund_state']" value="0">
									<eq name="order_info['order_state']" value="0">
										订单状态：用户已取消
									</eq>
									<eq name="order_info['order_state']" value="10">
										订单状态：商品已拍下，等待买家付款
									</eq>
									<eq name="order_info['order_state']" value="20">
										<php>if($order_info['tuanselect']==1&&$num<$order_info['tuannum']){</php>
										订单状态：拼团中
										<php>}elseif($order_info['tuanselect']==1&&$num==$order_info['tuannum']){</php>
										订单状态：拼团成功，等待卖家发货
										<php>}else{</php>
										订单状态：商品已付款，等待卖家发货
										<php>}</php>

									</eq>
									<eq name="order_info['order_state']" value="30">
										订单状态：商品已发货，等待卖家收货
									</eq>
									<eq name="order_info['order_state']" value="40">
										订单状态：确认收货
									</eq>
								</eq>
								<gt name="order_info['refund_state']" value="0">
									<eq name="order_info['refund_state']" value="1">
										<dd>
											退款申请已提交
										</dd>
										<php>
											if($order_edit==1){
										</php>
										<dd style="margin-top: 20px;">
											<a href="{:U('Mall/order_return',array('order_id'=>$order_info['order_id'],'status'=>2))}" style="background: #0043ff;padding: 4px 7px;color: #fff;border-radius: 4px;" onclick="{if(confirm('确是否同意?')){return true;}return false;}" >同意</a>
											<a href="{:U('Mall/order_return',array('order_id'=>$order_info['order_id'],'status'=>3))}" style="background: red;padding: 4px 7px;color: #fff;border-radius: 4px;">拒绝</a>
										</dd>
										<php>}</php>
									</eq>
									<eq name="order_info['refund_state']" value="2">
										已同意
									</eq>
									<eq name="order_info['refund_state']" value="3">
										已拒绝
									</eq>
									<eq name="order_info['refund_state']" value="4">
										等待客服打款
									</eq>
									<eq name="order_info['refund_state']" value="5">
										退换货完成
									</eq>
									<dl style="padding: 10px 25px;line-height: 20px;clear: both;margin: 0;margin-top: 15px;border-bottom: dotted 1px #E6E6E6;overflow: hidden;">

										<dt style="float: left;">处理方式：</dt>

										<dd style="text-align: left;">
											<eq name="order_info['refund_type']" value="1"> 我要退款，但不退货  </eq>
											<eq name="order_info['refund_type']" value="2"> 我要退款退货</eq>

										</dd>
									</dl>
									<dl style="padding: 10px 25px;line-height: 20px;clear: both;margin: 0;border-bottom: dotted 1px #E6E6E6;overflow: hidden;">
										<dt style="float: left;">退款原因：</dt>

										<dd style="text-align: left;">
											{$order_info['refund_reason']}
										</dd>
									</dl>
									<dl style="padding: 10px 25px;line-height: 20px;clear: both; margin: 0;border-bottom: dotted 1px #E6E6E6;overflow: hidden;">

										<dt style="float: left;">退款金额：</dt>

										<dd style="text-align: left;">
											{$order_info['refund_amount']}

										</dd>
									</dl>
									<php>if($order_info['refund_shipping_code']){</php>
									<dl style="padding: 10px 25px;line-height: 20px;clear: both; margin: 0;border-bottom: dotted 1px #E6E6E6;overflow: hidden;">

										<dt style="float: left;">退货物流：</dt>

										<dd style="text-align: left;">
											（{$order_info['refund_shipping_name']}）
											{$order_info['refund_shipping_code']}
										</dd>
									</dl>
									<neq name="order_info['refund_state']" value="4">
										<dl style="padding: 10px 25px;line-height: 20px;clear: both; margin: 0;border-bottom: dotted 1px #E6E6E6;overflow: hidden;">
											<php>
												if($order_edit==1){
											</php>
											<a href="{:U('Mall/order_return',array('order_id'=>$order_info['order_id'],'status'=>4))}"  onclick="{if(confirm('确是否确认收货?')){return true;}return false;}" style="background: #0043ff;padding: 4px 7px;color: #fff;border-radius: 4px;">确认收货</a>
											<php>}</php>

										</dl>
									</neq>
									<php>}</php>

								</gt>
							</div>
							<php>
								if($order_edit==1){
							</php>
							<div class="state-action">
								<eq name="order_info['refund_state']" value="0">
									<eq name="order_info['order_state']" value="0">
										<button class="zent-btn zent-btn-primary test-send-goods">已取消</button>
									</eq>
									<eq name="order_info['order_state']" value="10">
										<button class="zent-btn zent-btn-primary test-send-goods">等待付款</button>
									</eq>
									<eq name="order_info['order_state']" value="20">
										<php>if($order_info['tuanselect']==1&&$num<$order_info['tuannum']){</php>
										<button class="zent-btn zent-btn-primary test-send-goods">拼团中</button>
										<php>}elseif($order_info['tuanselect']==1&&$num==$order_info['tuannum']){</php>
										<button class="zent-btn zent-btn-primary test-send-goods" onclick="operation('delivery',{$order_info['order_id']})">立即发货</button>
										<php>}else{</php>
										<button class="zent-btn zent-btn-primary test-send-goods" onclick="operation('delivery',{$order_info['order_id']})">立即发货</button>
										<php>}</php>

									</eq>
									<eq name="order_info['order_state']" value="30">

										<button class="zent-btn zent-btn-primary test-send-goods" onclick="operation('logistics',{$order_info['order_id']})">查看物流</button>

									</eq>
								</eq>

							</div>
							<php>}</php>
						</div>
						<div class="state-remind-region">
							<div class="dashed-line"></div>
							<div class="state-remind">
								<div class="tixing">58代言提醒：</div>
								<ul>
									<li>如果无法发货，请及时与买家联系并说明情况后进行退款；</li>
									<li>买家申请退款后，须征得买家同意后再发货，否则买家有权拒收货物；</li>
									<li>买家付款后超过7天仍未发货，将有权申请客服介入发起退款维权；</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<table class="ui-table ui-table-simple goods-table order-detail-goods-table">
					<thead>
					<tr>
						<th style="width:8%;">商品图</th>
						<th class="cell-10" style="width:40%;">商品</th>
						<th style="width:10%;">价格(元)</th>
						<th style="width:10%;">数量</th>

						<th class="cell-13" style="width:10%;">小计(元)</th>
						<th  style="width:10%;">运费</th>
					</tr>
					</thead>
					<tbody>
					<foreach name="order_goods_info" item="vo">
						<tr>
							<td class="header-item">
								<div class="item-container clearfix">
									<div class="item-img">
										<a class="pic s50" href="{:U('shop/index',array('id'=>$vo['goods_id']))}" target="_blank"><img src="{$vo['goods_image']}" style="width: 50px; height: 50px;">
										</a>
									</div>

								</div>
							</td>
							<td>
								<div class="item-meta">
									<a class="item-link" href="{:U('shop/index',array('id'=>$vo['goods_id']))}" target="_blank">									{$vo['goods_name']}
									</a>

									<div class="item-props">
																						<span class="sku">
																						<notempty name="vo.goods_sku_spec"><span>规格：{$vo.goods_sku_spec}</span></notempty>&nbsp;
																						<notempty name="vo.goods_sku_style"><span>颜色：{$vo.goods_sku_style}</span></notempty>
																						</span>
									</div>
								</div>
							</td>

							<td class="header-price font-high-light">￥{$vo.goods_price}</td>
							<td class="header-count font-high-light">{$vo.goods_num}</td>
							<td class="header-favorable font-high-light">
								<div class="favorable-hight-light">￥{$vo['goods_price']*$vo['goods_num']}</div>
							</td>
							<td class="header-status font-high-light">
								<div class="font-high-light">￥{$vo['freight']}</div>
								<div class="font-high-light">( 快递 )</div>

							</td>


						</tr>
						<php>
							$count_fee=$count_fee+$vo['freight']; $count_price=$count_fee+($vo['goods_price']*$vo['goods_num']);
						</php>
					</foreach>
				</table>

			</div>
			<div class="order-total">

				<div class="total-count" style="height: 100px;">

					<div class="total-count-pay">
						<div class="total-count-pay-info" style="height: 60px;">
							<span>商品总额：￥{$count_price}</span>

							<em>+</em>
							<span>运费：￥{$count_fee}</span>

							<em>-</em>
							<span>优惠：￥0.00</span>

							<em>=</em>
							<span class="end second-color">订单总金额：￥
                                                <em class="y_cprice" <notempty name="order_price_action">style="text-decoration: line-through;"</notempty> >{$count_price+$count_fee}</em>
								<input type="text" name="y_iprice" id="y_iprice" value="{$count_price+$count_fee}" />
												<input type="button" id="y_button" value="确定" class="zent-btn zent-btn-primary test-send-goods"/>
												<notempty name="order_price_action"><br/><em class="xprice">￥{$order_price_action.xprice}</em></notempty>

                                          </span>
						</div>

						<!--<div style="color: #0000FF;">-->
						<!--如需修改总订单价格，请点击订单总价后的价格，即可修改-->
						<!--</div>-->

					</div>
				</div>
			</div>
			<div class="modal fade" id="Delivery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none;">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel">商品发货</h4>
						</div>
						<div class="modal-body">

							<div style="clear:both;"></div>
							<div class="form-group" id="express_input" style="height: 36px;">
								<select class="form-control input-lg" id="divlogistics_express_company" style="margin-bottom:5px;margin-right:15px;float:left;"></select>
								<div class="col-lg-2"><input type="text" id="divlogistics_express_no" class="form-control" placeholder="请填写快递单号" style="height: 32px;width: 270px;"></div>
							</div>
							<div id="receiver_info"></div>
						</div>

						<div class="modal-footer">
							<input type="hidden" id="delivery_order_id" value="">
							<button type="button" class="btn btn-info" onclick="orderDeliverySubmit()" style="display:inline-block;background: #00C0FF!important;">提交更改</button>
							<button type="button" class="btn btn-info" data-dismiss="modal" style="display:inline-block;background: red!important;">关闭</button>
						</div>
					</div>
				</div>
			</div>
			<div class="modal fade" id="orderlogistics" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display:none;height: 500px;">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header" style="float: left;width: 100%;">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h4 class="modal-title" id="myModalLabel" style="float: left;height: 23px;">物流信息</h4>
							<div style="float: right;height: 30px;line-height: 30px;padding-right: 22px;">物流单号:{$order_info['shipping_code']}&nbsp;({$order_info['shipping_name']})</div>
						</div>
						<div class="modal-body">

							<div style="clear:both;"></div>
							<div class="form-group" id="express_input" style="height: 330px;overflow: auto;">
								<div class="op_express_delivery_main" style="display: block;height: 330px;overflow: auto;">
									<div class="op_express_delivery_main_container" style="display: block;height: 330px;overflow: auto;">
										<div class="op_express_delivery_main_content opui-scroll-ctrl-content opui-scroll-onwheel"  style="display: block;height: 330px;overflow: auto;">
											<div style="zoom: 1;">
												<ul class="op_express_delivery_timeline_box"></ul>
											</div>
										</div>

									</div>
								</div>
							</div>
							<div id="receiver_info"></div>
						</div>

						<div class="modal-footer">

							<button type="button" class="btn btn-info" data-dismiss="modal" style="display:inline-block;background: red!important;">关闭</button>
						</div>
					</div>
				</div>
			</div>

			<script>
                /*****订单相关操作函数开始*****/
                function operation(operation_type, order_id) {

                    if(operation_type == 'delivery') {
                        orderDelivery(order_id); //发货
                    }
                    if(operation_type == 'logistics') {
                        orderlogistics(order_id); //查看物流
                    }
                }

                function orderDelivery(order_id) {
                    $("#Delivery").modal('show');
                    $("#divlogistics_express_company option").remove();
                    $("#Delivery .modal-body table tbody tr").remove();
                    $.ajax({
                        type: "post",
                        url: "{:U('mall/get_delivery')}",
                        data: {
                            'order_id': order_id
                        },
                        success: function(data) {

                            $("#delivery_order_id").val(order_id);
                            var receiver_info = '收货信息' + data['order_info']['address'];
                            $("#receiver_info").html(receiver_info);
                            var co_html = '';
                            co_html += '<option value="0" >请选择物流公司</option>';
                            for(var i = 0; i < data['express_company_list'].length; i++) {

                                if(data['express_company_list'][i]['is_enabled'] == '1') {
                                    co_html += '<option value="' + data["express_company_list"][i]["express_no"] + '">' + data["express_company_list"][i]["company_name"] + '</option>';
                                }
                            }
                            $("#divlogistics_express_company").append(co_html);
                            $("#divlogistics_express_company").val(0);

                        }
                    });
                }

                function orderDeliverySubmit() {
                    var order_id = $("#delivery_order_id").val();
                    var order_goods_id_array = '';

                    var express_name = $("#divlogistics_express_company").find("option:selected").text();

                    var express_company_id = $("#divlogistics_express_company").val();
                    var express_no = $("#divlogistics_express_no").val();

                    if(express_company_id == "0") {
                        layer.msg('必须选择物流公司');

                        return false;
                    }
                    if(express_no == "") {
                        layer.msg('必须填写快递单号');

                        return false;
                    }

                    $.ajax({
                        type: "post",
                        url: "{:U('mall/put_delivery')}",
                        data: {
                            'order_id': order_id,
                            "express_name": express_name,
                            "express_company_id": express_company_id,
                            "express_no": express_no
                        },
                        success: function(data) {
                            $("#Delivery").modal('hide');
                            if(data['code'] > 0) {
                                layer.msg(data["message"]);
                                setTimeout("window.location.reload()", 1000)
                            } else {
                                layer.msg(data["message"]);
                            }
                        }
                    });
                }

                function orderlogistics(order_id) {
                    $("#orderlogistics").modal('show');
                    var order_id = order_id;
                    $.ajax({
                        type: "post",
                        url: "{:U('mall/get_orderlogistics')}",
                        data: {
                            "order_id": order_id
                        },
                        beforeSend: function() {
                            html = '<div class="silider-express" style="padding: 77px;">';
                            html += '<div class="mask-layer-loading" style="text-align:center;">';
                            html += '<img src="/Store/css/order/mask_load.gif"/>';
                            html += '<div style="text-align:center;margin-top:10px;">努力加载中...</div>';
                            html += '</div>';
                            html += '</div>';
                            $('.op_express_delivery_timeline_box').html(html);

                        },
                        success: function(data) {
                            var data = eval('(' + data + ')');
                            var traces=data.Traces;
                            if(traces.length>0){
                                var newhtml ='';
                                for (var i = 0 ; i <traces.length; i++) {
                                    var html ='';
                                    if(i==traces.length-1){
                                        html+= '<li class="op_express_delivery_timeline_new c-clearfix">';
                                        html+= '<div class="op_express_delivery_timeline_title">';
                                        html+= '<div class="op_express_delivery_timeline_circle"><i class="c-icon op_express_delivery_timeline_circle_red"></i><i class="c-text c-text-danger c-text-mult c-gap-left-small">最新</i></div>';
                                    }else{
                                        html+= '<li class="op_express_delivery_timeline_label c-clearfix">';
                                        html+= '<div class="op_express_delivery_timeline_title">';
                                        html+= '<div class="op_express_delivery_timeline_circle"><i class="c-icon op_express_delivery_timeline_circle_blue"></i></div>';
                                    }


                                    html+= '<div class="op_express_delivery_timeline_info">'+traces[i]['AcceptTime']+'<br>'+traces[i]['AcceptStation']+'</div>';
                                    html+= '</div></li>';
                                    newhtml=html+newhtml;
                                }

                            }else{
                                var newhtml ='';
                                newhtml = '<div class="silider-express" style="padding: 77px;">';
                                newhtml += '<div class="mask-layer-loading" style="text-align:center;">';
                                newhtml += '<div style="text-align:center;margin-top:10px;">没有物流信息...</div>';
                                newhtml += '</div>';
                                newhtml += '</div>';
                            }
                            $('.op_express_delivery_timeline_box').html(newhtml);
                        }
                    });
                }

                // $(function(){
                //     $('.y_cprice').click(function(){
                //         $('.y_cprice').hide();
                //         $('#y_iprice').show();
                //         $('#y_button').show();
                //     })
                //     $('#y_button').click(function(){
                //         var cprice=$('#y_iprice').val();
                //         var patrn = /^(-)?\d+(\.\d+)?$/;
                //         if (patrn.exec(cprice) == null || cprice == "") {
                //             layer.msg('请输入正确的价格！！');
                //             return false
                //         }
                //         var order_id="{$_GET['id']}";
                //         $.ajax({
                //             type: "post",
                //             url: "{:U('Mall/edit_price')}",
                //             data: {
                //                 cprice:cprice,
                //                 order_id:order_id
                //             },
                //             dataType: "json",
                //             success: function(data){
                //                 if(data==1){
                //                     layer.msg('修改成功');
                //                     setTimeout('location.reload()',1000);
                //                 }else{
                //                     layer.msg('修改失败');
                //                 }
                //             }
                //         });
                //     })
                //
                //
                // })
			</script>

		</div>

		<!-- 公共的操作提示弹出框 common-success：成功，common-warning：警告，common-error：错误，-->
		<div class="common-tip-message js-common-tip">
			<div class="inner"></div>
		</div>
	</div>
</div>
